<?php
/**
 * Created by Benjamin.
 * Date: 2020/5/6
 * Time: 17:33
 */

namespace App\Model;


class CommonModel
{
    /**
     * aes加密
     * @param $str
     * @return string
     */
   static function aesEncrypt($str)
    {
        $instance = \EasySwoole\EasySwoole\Config::getInstance();
        return base64_encode(openssl_encrypt($str,'AES-128-CBC',$instance->getConf('APP.AES.AES_KEY'), 1, $instance->getConf('APP.AES.IV')));
    }

    /**
     * aes解密
     * @param $str
     * @return string
     */
  static  function aesDecrypt($str)
    {
        $instance = \EasySwoole\EasySwoole\Config::getInstance();
        return openssl_decrypt(base64_decode($str), 'AES-128-CBC', $instance->getConf('APP.AES.AES_KEY'), 1, $instance->getConf('APP.AES.IV'));
    }

}